Skip to content

fix(import): reads more trakt csv layouts and rated shows without ids - #3904

Merged
vladjerca merged 4 commits into
mainfrom
fix/import-csv-gaps
Dec 4, 2026
Merged

vladjerca merged 4 commits into
mainfrom
fix/import-csv-gaps

Conversation

@vladjerca

Copy link
Copy Markdown
Contributor

Four gaps in the Trakt CSV import made rows import as the wrong thing or not at all.

  • type vs media_type: some CSVs use type for the action (watch, rating, watchlist) and media_type for the kind. type: watch was read as a movie, so episode rows were looked up as movies by their show's TMDB id and could land on unrelated films.
    • Now media_type decides the kind and those type values decide the action.
    • Episode rows with season and episode numbers become positional episodes keyed by the show's tvdb, imdb or tmdb id.
    • showTmdb is new on positional episodes, carried through isPositionalItem, buildHistoryPayload and findNotFoundItems.
  • Prefixed id column: the guide names an id field with prefixed values (imdb_id:tt...), but the parser only read separate id columns.
    • It now splits prefix:value into the matching id, and reads a bare tt... value as an IMDb id.
    • Separate columns still win when both are present.
  • Rated shows with only title and year: these were dropped without notice, because the ratings payload needs an id.
    • They now go through the existing show matching.
    • Shows that still don't match are listed in the unresolved CSV, which now carries rating and rated_at so they can be re-imported.
  • Guide: the type field now says rows without a type import as movies. Only the English source changed; translations follow.

Verified

  • bunx vitest --run src/lib/sections/settings/import: 440 passed, up from 400 on main
  • biome and eslint are clean on the touched files
  • Each new branch was broken on purpose, and a named test failed each time
  • The sync request schema accepts tmdb in show ids (showIdsRequestSchema)

Not verified

  • Full type check (CI runs it)
  • A real upload imported end to end
  • Episode ratings that carry only show ids are still not sent: the ratings API has no positional form

@vladjerca

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-04T18:09:55.674087Z f702a7f Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: f702a7f825

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@vladjerca
vladjerca marked this pull request as ready for review December 4, 2026 18:07
@vladjerca
vladjerca merged commit 80980ab into main Dec 4, 2026
27 checks passed
@vladjerca
vladjerca deleted the fix/import-csv-gaps branch December 4, 2026 18:07

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f702a7f825

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +173 to +176
ids: { tmdb: ids.tmdb },
showTvdb: ids.tvdb,
showImdb: ids.imdb,
showTmdb: ids.tmdb,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve positional show IDs in the unresolved CSV

When a media_type: episode row is rejected by Trakt, this moves its TVDB/IMDb identifiers exclusively into showTvdb/showImdb, but toUnresolvedCsv.ts serializes only item.ids.*. The downloaded skipped CSV therefore loses the definitive show IDs; on re-import, an episode without both a usable title and year is dropped, while others fall back to potentially ambiguous title matching. Serialize these parent-show IDs in a form that the parser can reconstruct.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant